package IO流.文件字符流;

import java.io.*;

public class $01_异常处理 {
    public static void main(String[] args){

        //创建输入流和输出流
        Reader reader= null;
        Writer writer=null;
        /**try (Reader reader=new FileReader("F:\\javayws2.txt");
         * Writer writer=new FileWriter("F:\\javayws1.txt");){
         *
         * }
         * */
        try {
            reader = new FileReader("F:\\javayws2.txt");
            writer=new FileWriter("F:\\javayws1.txt");
            char[] n=new char[1024];
            int len =reader.read(n);
            while (len!=-1){
                writer.write(n,0,len);//写一个字符到文件
                System.out.println(n);
                len=reader.read(n);//再读一个字符到中转站
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        //关闭输入流和输出流

    }
}
